home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / BBEdit / MacBob 1.0ß2 / Source / Exceptions.c < prev    next >
Encoding:
Text File  |  1995-12-11  |  1.0 KB  |  67 lines  |  [TEXT/KAHL]

  1. /***
  2.   *
  3.   *    Exceptions.c - Assembly language functions
  4.   *    Copyright © 1992-1995 by Christopher E. Hyde.  All rights reserved.
  5.   *
  6.   *    Version:    1.06                11/95
  7.   *
  8.   ***/
  9.  
  10. //#include "Exceptions.h"
  11.  
  12.  
  13. typedef struct FailInfo FailInfo;
  14.  
  15. struct FailInfo {
  16.     long        jumpBuf[12];        // old 68K:  D2-D7,PC,A2-A4,A6,SP
  17.     FailInfo*    nextInfo;            // Next in stack.
  18. };
  19.  
  20. extern FailInfo*    gTopHandler;    // Pointer to the top level (most recent) handler
  21. extern short        gFailE;
  22. extern long        gFailM;
  23.  
  24.  
  25. #define    savedRegs        D2-D7/A0/A2-A4/A6/A7
  26. #define    regA0        6        // Index of register A0
  27.  
  28.  
  29. #pragma options(!require_protos)
  30.  
  31. int
  32. DoTry (/*FailInfo* fi*/)
  33. {
  34.     asm {
  35.         MOVE.L    (A7)+,A0            // Get return address
  36.         MOVE.L    (A7),A1                // FailInfo*
  37.         MOVEM.L    savedRegs,(A1)
  38.         MOVE.L    gTopHandler,FailInfo.nextInfo(A1)
  39.         MOVE.L    A1,gTopHandler        // Set new top handler
  40.         MOVEQ    #1,D0                // Return 1
  41.         JMP        (A0)
  42.     }
  43. }
  44.  
  45.  
  46. #if 0
  47. void
  48. Testing ()
  49. {
  50.     asm {
  51.         MOVE.L    0x0130,D0
  52.         SUB.L    A7,D0
  53.  
  54.         MOVE.L    A7,D0
  55.         SUB.L    0x0130,D0
  56.  
  57.         TST.L    d1
  58.         BEQ.S    @2
  59. @1        MOVE.B    (a1)+,(a0)+
  60.         SUBQ.L    #1,d1
  61.         BNE.S    @1
  62.  
  63. @2        RTS
  64.     }
  65. }
  66. #endif
  67.